﻿
//////////////////////////////////////////////////////////////////////////////
//
// Copyright © 1998-2024 Glodon Company Limited.
//
// Permission is hereby granted, free of charge, to any person obtaining a
// copy of this software and associated documentation files (the “Software”),
// to deal in the Software without restriction, including without limitation
// the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
// sell copies of the Software, and to permit persons to whom the Software is
// furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in
// all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
// THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
//
//////////////////////////////////////////////////////////////////////////////
#pragma once

#include "WeakPtr.h"
#include "CommandBase.h"

namespace gcmp
{
    class ElementId;
    class IDocument;
    class IGraphicsNode;
    class GraphicsNodeId;
}

namespace Sample
{
    class IGraphicsNode_Wrapper;

    class GNodeUtility
    {   
    public:
        // 递归调用函数，逐层建立由几何图形节点组织的图形表达的节点数
        static gcmp::OwnerPtr<IGraphicsNode_Wrapper> CreateGNodeWrapperTree(gcmp::IDocument* pDoc, gcmp::ElementId id,
            gcmp::IGraphicsNode* pGNode, gcmp::IGraphicsNode* rootGNode, bool isReadOnly, IGraphicsNode_Wrapper* pParent);

        // 根据IGraphicsNode的GraphicsNodeType对IGraphicsNode_Wrapper设置响应的数据，用于GRep浏览器的信息显示和修改
        static void VisitGNode(gcmp::IGraphicsNode* pGNode, IGraphicsNode_Wrapper* pGNodeWrapper);

        // 从图形节点树中得到一个图形节点的std::vector<GraphicsNodeId>，
        // std::vector<GraphicsNodeId>用于创建IGraphicsNodeReference，用于拾取
        static std::vector<gcmp::GraphicsNodeId> CollectGNodeIds(const std::vector<const gcmp::IGraphicsNode*>& pNodePath);
    };
}

